/*
 * Copyright (C) 2018 The Asiainfo-Ability Authors
 *
 *      Licensed under the Apache License, Version 2.0 (the "License");
 *      you may not use this file except in compliance with the License.
 *      You may obtain a copy of the License at
 *
 *          http://www.apache.org/licenses/LICENSE-2.0
 *
 *      Unless required by applicable law or agreed to in writing, software
 *      distributed under the License is distributed on an "AS IS" BASIS,
 *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *      See the License for the specific language governing permissions and
 *      limitations under the License.
 */

package org.asiainfo.ability.gateway.service;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.asiainfo.ability.gateway.dao.ServiceDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: visen
 * @Date: 2018/2/1
 * @Description:
 */
@Api(value="博客相关接口1111")
@RestController
@Component
public class AdminService {

    @Autowired
    private ServiceDao dao;

    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=16000,rollbackFor=Exception.class)
    public void deleteInstances(String[] idArr) throws Exception{
        for(int i = 0, len = idArr.length; i < len; i++) {
            dao.deleteInstance(Long.parseLong(idArr[i]));
        }
    }

    @ApiOperation(value="创建用户", notes="根据User对象创建用户")
    @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "")
    @Cacheable(value="t1")
    public String test1(String id, String name){
       // org.springframework.cloud.netflix.ribbon.apache.RibbonLoadBalancingHttpClient
        //DefaultClientConfigImpl
        String s = "System" + System.currentTimeMillis();
        System.out.println(s + "===============");
        return s;
    }
}
